package com.isasc.demo.pooled.mypool;

/**
 * @author: ywy
 * @date: 2022-10-17
 * @desc:
 */
public class Person implements Runnable {

    private MyPool<ShareBike> bikeMyPool;

    public Person(MyPool<ShareBike> bikeMyPool) {
        this.bikeMyPool = bikeMyPool;
    }

    @Override
    public void run() {
        // 模拟借还频繁
        for (int i = 0; i < 10000; i++) {
            try {
                ShareBike shareBike = bikeMyPool.borrowObject(ShareBike.class);
                System.out.println(shareBike);
                bikeMyPool.returnObj(shareBike);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
